package com.goods.lucene.tool;

import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.Version;
import org.wltea.analyzer.lucene.IKAnalyzer;

/**
 * 
 * @author penghui.li
 *
 */
public class FclubBooleanQuery {

	public static BooleanQuery getBooleanQuery(String str, String resourceField) throws Exception {
		QueryParser qp = new QueryParser(Version.LUCENE_35, resourceField, new IKAnalyzer());
		qp.setAllowLeadingWildcard(true);
		Query query = qp.parse(str);
		BooleanQuery bquery = new BooleanQuery();
		bquery.add(query, BooleanClause.Occur.MUST);
		return bquery;
	}
}
